package com.gms.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.BaseDaoImpl;

import com.gms.dao.ProductDao;
import com.gms.domain.Product;

public class ProductDaoImpl extends BaseDaoImpl<Product> implements ProductDao{

	@Override
	public List<String> findAllProductByBigProperty(String bigProperty) {
		List<String> proList = new ArrayList<String>();
		String sql = "select DISTINCT property from product where bigproperty = ?";
		proList = this.findBySQLQuery(sql, bigProperty);
		return proList;
	}

	@Override
	public List<Product> findAllProductByProperty(String property) {
		List<Product> list = new ArrayList<Product>();
		String hql = "from Product where property = ?";
		list = this.findByHql(hql, property);
		return list;
	}

	@Override
	public Product findProductById(Integer productId) {
		// TODO Auto-generated method stub
		return this.findById(productId);
	}

	@Override
	public List<Product> findProductByState(String state) {
		List<Product> list = new ArrayList<Product>();
		String hql = "from Product where state = ?";
		list = this.findByHql(hql, state);
		return list;
	}

	@Override
	public List<Product> findAllRealProductByBigProperty(String bigProperty) {
        List<Product> proList = new ArrayList<Product>();
        proList = this.findByProperty("BIGPROPERTY", bigProperty);
        
		return proList;
	}
	@Override
	public List<Product> findProductByProductName(String productName) {
		// TODO Auto-generated method stub
		List <Product> listPd = new ArrayList<Product>();
		String hql = "from Product where productName like '%"+productName+"%'";
		System.out.println(hql);
		listPd = this.findByHql(hql, null);
		
		return listPd;
	}
	
	

}
